<template>
  <div class="index">
    <el-container>
      <el-header style="display: flex">
        <div style="display: flex">
          <img class="imgs" src="../images/index/图层 2.png" alt="" />
          <div class="title">后台管理系统</div>
        </div>

        <div
          class="hello"
          style="color: #fff; line-height: 60px; font-size: 16px"
        >
          <a @click="indexs" style="cursor: pointer;">首页</a>，欢迎回来{{ adminname }}
        </div>

        <div
          class="right"
          style="color: #fff; line-height: 60px; font-size: 16px;"
          @click="open"
        >
          【退出】
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <div class="Conbranner">
            <el-menu
              :default-active="$route.path"
              text-color="#666666"
              class="el-menu-vertical-demo"
              router
            >
              <el-menu-item index="/visitor">
                <i class="iconfont icon-chakanfangke">
                  <span class="function">访客记录</span>
                </i>
                <span slot="title"></span>
              </el-menu-item>
              <el-menu-item index="/section">
                <i
                  class="
                    iconfont
                    icon-suyaniconchanpinleibufenzuodaohangbufen87
                  "
                  ><span class="function">部门管理</span></i
                >
                <span slot="title"></span>
              </el-menu-item>
              <el-menu-item index="/admin">
                <i class="iconfont icon-xitongguanliyuan"
                  ><span class="function">管理员</span></i
                >
                <span slot="title"></span>
              </el-menu-item>
              <el-menu-item index="/auditlog">
                <i class="iconfont icon-shenhe"
                  ><span class="function">审核日志</span></i
                >
                <span slot="title"></span>
              </el-menu-item>
              <el-menu-item index="/reviewer">
                <i class="iconfont icon-hexiaoqueren"
                  ><span class="function">核销人员管理</span></i
                >
                <span slot="title"></span>
              </el-menu-item>
              <el-menu-item index="/news">
                <i class="iconfont icon-zhihuixiaoyuan"
                  ><span class="function">校园动态</span></i
                >
                <span slot="title"></span>
              </el-menu-item>
            </el-menu>
          </div>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      adminname: "",
    };
  },
  mounted() {
    this.getOpen()
    this.Getadminname()
  },
  methods: {
    // 退出
    open() {
      this.$confirm("确定要退出登陆吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "退出成功!",
          });
          this.$router.push("/");
          sessionStorage.clear();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    indexs(){
      this.$router.push('/visitorindex')
    },
    getOpen() {
      if(sessionStorage.getItem('token')==null){
        this.$router.push("/")
      }
    },
    Getadminname() {
      const adminname = sessionStorage.getItem("admin");
      this.adminname = JSON.parse(adminname).admin_name;
    },
    handleOpen(key, keyPath) {
      // console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
    changPath(path) {
      // (this.$route.fullPath == path) && this.$router.push(path)
      // console.log(this.$route);
      // sessionStorage.setItem('path',path)
    },
  },
};
</script>
<style scoped>
.el-menu {
  background: #23262e;
  height: 900px;
}
.right{
  cursor: pointer;
}
.Conbranner .el-menu-item {
  height: 70px;
  margin: 0;
  position: relative;
  display: flex;
}
.el-header {
  padding: 0px;
  background: #23262e;
  justify-content: space-between;
}

.el-menu[data-v-a83bd3b0] {
  background: #23262e;
  height: 910px;
}

.Conbranner .el-menu-item .iconfont .function {
  position: absolute;
  top: 5px;
  left: 60px;
  font-size: 14px;
  margin-left: 10px;
  color: currentcolor;
  font-size: 15px;
}
</style>
<style lang="less">
.imgs {
  width: 50px;
  height: 50px;
  margin: 5px 0px 0px 5px;
}
.Conbranner .el-menu-item {
  height: 70px;
  margin-bottom: 25px;
  position: relative;
  .iconfont {
    font-size: 30px;
    // margin: auto;
    margin-top: 5px;
    // color: #666;
    .function {
      position: absolute;
      top: 5px;
      left: 60px;
      font-size: 14px;
      margin-left: 10px;
    }
  }
}
.el-breadcrumb {
  line-height: 50px;
  margin-left: 50px;
}
.el-header,
.el-footer {
  background-color: #f4f4f4;
  color: #333;
  text-align: center;
}
.el-header {
  width: 100%;
  position: fixed;
  top: 0px;
  left: 0px;
  height: 54px;
  box-sizing: border-box;
  margin-bottom: 60px;
  z-index: 2000;
}
.el-header .title {
  width: 139px;
  height: 60px;
  line-height: 60px;
  background-color: #23262e;
  color: #fff;
  font-size: 20px;
}
.el-aside {
  background-color: #f4f4f4;
  color: #333;
  text-align: center;
  line-height: 200px;
  position: fixed;
  // width: 54px;
  top: 60px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  margin-left: 90px;
  margin-top: 60px;
  background-color: #fff;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-container {
  background: #fff;
}

.el-menu-item {
  display: flex;
  font-size: 14px;
}

.el-main {
  background: #fff;
  padding-left: 140px !important;
}

.el-aside {
  background: #eee;
}
</style>